﻿package com.jfdesgagne.jfdesgagne09.section.showcase.service {
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import com.jfdesgagne.jfdesgagne09.core.service.RemotingGateway;
	import com.jfdesgagne.jfdesgagne09.section.showcase.event.ProjectsLoadedEvent;
	import fl.lang.Locale;
	
	
	public dynamic class ProjectsService extends EventDispatcher {
		private var _gateway:RemotingGateway;
		public const PRODUCTLOADED_EVENT:String = "productloaded";
		
		public function ProjectsService($gateway:RemotingGateway) {
			this._gateway = $gateway;
		}
		
		public function loadProjects():void {
			this._gateway.run("com.jfdesgagne09.Projects.getProjects", this.projectLoadedHandler, [Locale.getDefaultLang()]);
		}
		
		public function projectLoadedHandler($data:Object):void {
			this.dispatchEvent(new ProjectsLoadedEvent(ProjectsLoadedEvent.COMPLETE, $data));
		}
		
	}
}